﻿using Ef_Core_learn;
using Microsoft.EntityFrameworkCore;

namespace ConsoleApp1;

class Program
{
    static void Main(string[] args)
    {
        using (var context = new MyContext())
        {
            // 插入一个 Blog 实体
            //var blog = new Blog
            //{
            //    Url = "https://example.com"
            //};
            //context.Blogs.Add(blog);

            // 插入一个 RssBlog 实体，继承自 Blog
            var rssBlog = new RssBlog
            {
                Url = "https://rss.example.com",
                RssUrl = "https://rss.example.com/feed"
            };
            context.RssBlog.Add(rssBlog);
            //context.RssBlogs.Add(rssBlog);

            // 提交更改到数据库
            context.SaveChanges();
        }

        // using (var dbContext = new MyContext())
        // {
        //     var blogs = dbContext.Blog.ToList();
        //     Console.WriteLine();
        // }

        Console.WriteLine("Hello, World!");
    }
}